use std::path::PathBuf;
use clap::Parser;
use tokio::fs;
use wanmesh_server::app::Config;

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
    /// 配置文件地址
    #[arg(long, default_value = "/opt/wanmesh-server/etc/config.toml")]
    config: PathBuf,
}

#[tokio::main]
async fn main() {
    let args = Args::parse();

    let config_content = fs::read_to_string(&args.config).await.unwrap();

    let config: Config = toml::from_str(&config_content).unwrap();

    let app = wanmesh_server::app::App::new(config);

    if let Err(e)  = app.run().await {
        panic!("{:?}", e);
    }
}